#include <string>
#include <iostream>

using namespace std;

int main() {
	string s;
	string s1 ="";
	cout << "Enter string:" << endl;
	getline(cin,s);
	int i = 0;
	for(;i < s.size();i++) {
		if(s[i] == '(' or s[i] == '[' or s[i] == '{' or s[i] == '<' ){
			s1 += s[i];
                       }
		if(s[i] == ')' and s1[s1.size()-1] == '(') {
		s1.pop_back();
                        }
		else if(s[i] == ']' and s1[s1.size()-1] == '[') {
		s1.pop_back();	
				        }
		else if(s[i] == '}' and s1[s1.size()-1] == '{') {
		s1.pop_back();	
				        }
        else if(s[i] == '>' and s1[s1.size()-1] == '<') {
		s1.pop_back();
                        }
        else if(s[i] == ']' and s1[s1.size()-1] != '[')	{
             break;
				        }
		else if(s[i] == ')' and s1[s1.size()-1] != '(')	{
             break;
				        }
		else if(s[i] == '}' and s1[s1.size()-1] != '{')	{
             break;
				        }
		else if(s[i] == '>' and s1[s1.size()-1] != '<')	{
             break;
                        }
		else if((s[i] == ')' or s[i] == ']' or s[i] == '}' or s[i] == '>') and s1 == "") {
		     break;
                        }
		
	           }
		if (i == s.size() and s1.size()==0){
               cout << "True";
               }
               
        else if(i != s.size() or s1.size() !=0){
               cout << "False";
             }
		return 0;	
}
